package com.xc58.highreactor.seril;

import static com.xc58.highreactor.util.ByteUtil.*;

import java.io.InputStream;

import com.xc58.highreactor.exception.ParseDataException;

public class ShortSerializer implements ISerializer<Short>{

	public byte[] serialize(Short rawObject) throws Exception {
		return getByteFormShort(rawObject.shortValue());
	}
	
	public Short deserialize(InputStream input) throws Exception {
		byte[] bytes = new byte[2];
		if(input.read(bytes) < 2){
			throw new ParseDataException();
		}
		return toShort(bytes);
	}

}
